package com.bianguo.android.iocdemo.view.activity;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.View;

import com.bianguo.android.injectlibrary.annotations.ContentView;
import com.bianguo.android.injectlibrary.annotations.InjectView;
import com.bianguo.android.injectlibrary.annotations.OnClick;
import com.bianguo.android.iocdemo.R;
import com.bianguo.android.iocdemo.enums.DrawEnum;
import com.bianguo.android.iocdemo.view.widget.DrawBitmapView;

@ContentView(R.layout.activity_draw)
public class DrawActivity extends BaseActivity {

    @InjectView(R.id.draw_view)
    DrawBitmapView drawView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @OnClick({R.id.draw_save, R.id.draw_reset, R.id.draw_red,
            R.id.draw_green, R.id.draw_blue, R.id.draw_normal,
            R.id.draw_moasic})
    public void onClickBk(View view) {
        switch (view.getId()) {
            case R.id.draw_save:
                drawView.saveToGallery("aa.jpeg", "test", Bitmap.CompressFormat.JPEG, 100);
                break;
            case R.id.draw_reset:
                drawView.reset();
                break;
            case R.id.draw_red:
                drawView.setLineColor(ActivityCompat.getColor(this, R.color.pink));
                break;
            case R.id.draw_green:
                drawView.setLineColor(ActivityCompat.getColor(this, R.color.green));
                break;
            case R.id.draw_blue:
                drawView.setLineColor(ActivityCompat.getColor(this, R.color.blue));
                break;
            case R.id.draw_normal:
                drawView.setDrawType(DrawEnum.NORMAL_LINE);
                break;
            case R.id.draw_moasic:
                drawView.setDrawType(DrawEnum.MOSAIC_LINE);
                break;
        }
    }
}
